﻿using System;

namespace OpenLS.Spreadsheet.Performance
{
#if PERFORMANCE

    public struct PerformanceCounter
    {
        private DateTime startTime;
        public TimeSpan TotalTime;
        public int Count;

        public void Start()
        {
            startTime = DateTime.Now;
        }
        public void Stop()
        {
            this.TotalTime = this.TotalTime + (DateTime.Now - startTime);
            Count++;
        }
        public double AverageTime
        {
            get
            {
                if (Count == 0)
                    return -999;
                return TotalTime.Milliseconds/(double)Count/1000d;
            }
        }
    }
    public class PerformanceData
    {
        public PerformanceCounter CellDisplayInfo;
        public PerformanceCounter TextHeight;
        static PerformanceData _current;

        public static PerformanceData Current{get{
if (_current == null)
        _current = new PerformanceData();
        return _current;}
}

        public void Reset()
        {
            this.CellDisplayInfo = new PerformanceCounter();
            this.TextHeight = new PerformanceCounter();
        }
    }
#endif
}